package org.me.marble;

import java.util.ArrayList;

/**
 *
 * @author tungi
 */

public class Triangle{
    private int backjump;
    private Vector a,b,c;
    private Vector normal;
    private ArrayList<Integer> forejump;
    
    public Triangle(Vector a,Vector b,Vector c,ArrayList<Integer> forejump,int backjump){
        this.a=a;
        this.b=b;
        this.c=c;
        this.backjump=backjump;
        this.forejump=forejump;
        normal=Geometry.getPlaneNormal(a,b,c);
        normal.Normalize();
    }

    public Vector getPoint(int id){
        switch(id){
            case 0: return a;
            case 1: return b;
            case 2: return c;
            default: return null;
        }
    }

    public Vector getNormal(){
        return normal;
    }

    public ArrayList<Integer> getForeJump(){
        return forejump;
    }

    public int getBackJump(){
        return backjump;
    }

    public boolean isPart(Vector point){
        return Geometry.isPartOfTriangle(point,a,b,c,normal);
    }

    public boolean isPartProj(Vector point){
        return Geometry.isPartOfTriangle(new Vector(point.getX(),0,point.getZ()),
                new Vector(a.getX(),0,a.getZ()),new Vector(b.getX(),0,b.getZ()),
                new Vector(c.getX(),0,c.getZ()),new Vector(0,1,0));
    }
}
